package java8;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class LambdaStreamMap {
    public static void main(String[] args) {
        List<String> nameStr = Arrays.asList("Monkey", "Lion", "Giraffe", "Lemur");
//        Map<String, Object> maps = new HashMap<>();
//        maps.put("a", "aa");maps.put("b", "bb");maps.put("c", "cc");maps.put("d", "dd");maps.put("e", "ee");
//        maps.forEach((k, v) -> System.out.println(k + " " + v));
//        nameStrs.forEach(v -> System.out.println(v));

        //String::toUpperCase 和 s -> s.toUpperCase() 效果一样
        List<String> nameStrCha = nameStr
                .stream()
                .map(String::toUpperCase)
                .collect(Collectors.toList());

        System.out.println(nameStrCha);

        System.out.println("---------------");
        String[] array = {"a", "b4", "c", "d", "e"};
//        Stream.of(array)
//                .mapToInt(String::length)
//                .forEach(System.out::println);

        Arrays.stream(array).map(String::length).forEach(System.out::println);

    }
}
